package edu.ustb.efws.security.autoconfigure;

import edu.ustb.efws.security.SecProperties;
import edu.ustb.efws.security.authenticate.AuthenticateService;
import edu.ustb.efws.security.token.MemTokenService;
import edu.ustb.efws.security.token.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 安全配置
 *
 * @author TS Group
 */
@Configuration
@EnableConfigurationProperties({SecProperties.class})
public class SecConfigure {
    private final SecProperties authProperties;

    @Autowired
    public SecConfigure(SecProperties authProperties) {
        this.authProperties = authProperties;
    }

    @Bean
    @ConditionalOnMissingBean(TokenService.class)
    public TokenService tokenService(){
        return new MemTokenService();
    }

    @Bean
    public AuthenticateService authenticateService(){
        return new AuthenticateService(authProperties);
    }
}
